<?php
include 'checkLogin.php';

@$branch_id = $_REQUEST['branch_id'];

include 'db/li.php';

@$branch_workers = dbSelectAll('select id from worker where branch_id=:id',array('id'=>$branch_id));

if(!empty($branch_workers)){
	include 'cssHeader.php';?>
			<div class='modal'>
				<div class='myDialog'>
					<div class='modal-content'>
						<div class='modal-header'>
							<div class='modal-title'>错误提示</div>
						</div>
						<div class='modal-body'>
							删除失败，请先删除此北门下所属职员
						</div>
						<div class='modal-footer'>
							<a class='btn btn-default' data-dismiss='modal'>返回</a>
						</div>
					</div>
				</div>
			</div>
		</body>
	</html>
<?php }else{
	@$flog = dbDelete('delete from branch where id=:id',array('id'=>$branch_id));
	if(!$flog){
		include 'cssHeader.php';?>
				<div class='modal'>
					<div class='myDialog'>
						<div class='modal-content'>
							<div class='modal-header'>
								<div class='modal-title'>错误提示</div>
							</div>
							<div class='modal-body'>
								删除失败
							</div>
							<div class='modal-footer'>
								<a class='btn btn-default' data-dismiss='modal'>返回</a>
							</div>
						</div>
					</div>
				</div>
		</body>
	</html>
	<?php }else{
		header('Refresh:0;url=branchList.php');
	}
}
